<?php
/**
 * Notes:
 * Created by PhpStorm.
 * Author: TS
 * Date: 2019/10/4
 * Time: 13:13
 */

namespace app\model;


use think\Model;

class MapArea extends Model
{
    protected $pk = 'area_id';
    public function getByArea(){
        return self::join('map_city','map_city.city_id = map_area.city_id')
            ->join('map_province','map_area.province_id = map_province.province_id')
            ->field(['map_area.province_id,map_area.city_id,map_area.area_id,area_name,city_name,province_name'])
            ->select();
    }
    public function getByAreaId($area_id){
        return self::join('map_city','map_city.city_id = map_area.city_id')
            ->join('map_province','map_area.province_id = map_province.province_id')
            ->field(['map_area.province_id,map_area.city_id,map_area.area_id,area_name,city_name,province_name'])
            ->where(['map_area.area_id' => $area_id])
            ->find();
    }
    public function getArea($city_id){
        return self::where(['city_id' => $city_id])->select();
    }

}